package br.ufmg.ubicomp.notification;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;

public class NotificationMessage {

	private NotificationType type;
	private long time;
	private String text;
	private String origin;
	private Level level;
	
	public NotificationMessage(NotificationType type, long time, String text,
			String origin) {
		this.type = type;
		this.time = time;
		this.text = text;
		this.origin = origin;
	}

	public NotificationMessage(NotificationType type, long time, String text,
			String origin, Level level) {
		this(type, time, text, origin);
		this.level = level;
	}

	public Level getLevel() {
		return level;
	}

	public void setLevel(Level level) {
		this.level = level;
	}



	public String getOrigin() {
		return origin;
	}

	public void setOrigin(String origin) {
		this.origin = origin;
	}

	public NotificationType getType() {
		return type;
	}

	public void setType(NotificationType type) {
		this.type = type;
	}

	public long getTime() {
		return time;
	}
	
	public void setTime(long time) {
		this.time = time;
	}
	public String getText() {
		return text;
	}
	public void setText(String text) {
		this.text = text;
	}
	
	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder();
		sb.append(getFormattedTime()).append(" : ");
		sb.append(type.getName()).append(" : ").append("\n");
		sb.append(origin).append(" : ").append(text);
		return sb.toString();
	}

	private String getFormattedTime() {
		return new SimpleDateFormat("hh:mm").format(new Date(time));
	}
	
}
